package org.spdata.utils;

import org.spdata.tsdb.dto.DataPoint;

import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;

public class SpDataObjectMapper extends ObjectMapper {
	private static final long serialVersionUID = 1L;

	public SpDataObjectMapper(){
		super();
		this.setSerializationInclusion(Include.NON_NULL);  
		SimpleModule simpleModule = new SimpleModule("SimpleModule", Version.unknownVersion());
		simpleModule.addSerializer(Float.class, new FloatSerializer());
		this.registerModule(simpleModule);
	}
	
	public static void main(String[] args) throws Exception {
		ObjectMapper mapper  = new SpDataObjectMapper();
		DataPoint dp = new DataPoint();
		dp.setMetric("temp");
		dp.setTime(System.currentTimeMillis());
		dp.setValue(23.34556f);
		System.out.println(mapper.writeValueAsString(dp));
	}
}
